<!DOCTYPE html>
<html>

<head>
    <title>北京站网格化系统</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Fonts -->
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/bootstrap-switch.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/checkbox3.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/dataTables.bootstrap.css">
    <!-- <link rel="stylesheet" type="text/css" href="../lib/css/select.bootstrap.min.css"> -->
    <link rel="stylesheet" type="text/css" href="../lib/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.datetimepicker.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/validform.min.css">
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="../lib/css/common/style.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/themes/flat-blue.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/common/newstyle.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/zc-common.css">
</head>

<body class="flat-blue">
    <div class="app-container expanded">
        <div class="row content-container">
            <nav class="navbar navbar-default navbar-fixed-top navbar-top">
                <div class="container-fluid app-header">
                    <div class="navbar-header">
                        <button type="button" class="navbar-expand-toggle fa-rotate-90">
                            <i class="fa fa-bars icon"></i>
                        </button>
                        <!-- 三级导航 -->
                        <top-nav></top-nav>
                    </div>
                    <right-info></right-info>
                </div>
            </nav>
            <div class="side-menu-wrap">
                <!-- 一二级导航 -->
                <side-menu></side-menu>
            </div>
            <!-- Main Content -->
            <div class="container-fluid">
                <div class="side-body padding-top">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card card_list">
                                <div class="elm-wrap nav">
                                    <button type="button" class="btn btn-info" onclick="editing('quantitave')">添加任务</button>
                                    <button type="button" class="btn btn-default" onclick="delingModal('quantitave')">批量删除</button>
                                    <form class="form-inline navbar-right mgr0">
                                        <div class="form-group">
                                          <label for="search_name">项目名称：</label>
                                          <input type="text" id='search_name' class="form-control search_name" placeholder="请输入模版名称">
                                        </div>
                                        <div class="form-group" style="margin-left:10px">
                                            <label for="search_uwork" class="control-label">巡视类别： </label>
                                            <select name="search_uwork" id="search_uwork" class="form-control search_uwork">
                                                <option value="">全部</option>
                                                <option value="3">岗位</option>
                                                <option value="1">人员</option>
                                            </select>
                                        </div>
                                        <div class="form-group" style="margin-left:10px">
                                            <label for="search_type" class="control-label">考核周期： </label>
                                            <select name="search_type" id="search_type" class="form-control search_type">
                                                <option value="">全部</option>
                                                <option value="2">上线</option>
                                                <option value="1">按月</option>
                                            </select>
                                        </div>
                                        <button type="button" class="btn btn-info" onclick="searching('quantitave')"  style="margin-left:10px">搜索</button>
                                      </form>
                                </div>
                                <div class="elm-wrap people-el">
                                    <div class="alert alert-info" role="alert" style="margin-bottom:0px">
                                            已选择 <span class="dtcount">0</span> 项  |   删除后的数据无法恢复
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div>
                                                <div class="card-body">
                                                    <table class="table table-striped quantable" cellspacing="0" width="100%">
                                                        <thead>
                                                            <tr>
                                                                <th class="select-checkbox datatable-checkall">  
                                                                </th>
                                                                <th>任务编号</th>
                                                                <th>模版名称</th>
                                                                <th>巡视岗位人员</th>
                                                                <th>考核类型</th>
                                                                <th>巡视网格</th>
                                                                <th>生效日期</th>
                                                                <th>更新时间</th>
                                                                <th>操作</th>
                                                            </tr>
                                                        </thead>
                                                        <tfoot>
                                                            <tr>
                                                                <th></th>
                                                                <th>任务编号</th>
                                                                <th>模版名称</th>
                                                                <th>巡视岗位人员</th>
                                                                <th>考核类型</th>
                                                                <th>巡视网格</th>
                                                                <th>生效日期</th>
                                                                <th>更新时间</th>
                                                                <th>操作</th>
                                                            </tr>
                                                        </tfoot>
                                                        <tbody>
                                                                
                                                        </tbody>
                                                        
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                     
                                </div> 
                            </div>
                            <div class="card card_edit">
                                <div class="card-body quantitavevue ss_form">
                                <div class="elm-wrap" style="position: relative" v-for="(info,index) in infos" :key="info.ids" :class="iseven(index)">
                                <p @click="removeNewQuan(index)" class="delaccbtn">&times;</p>
                                <div class="elm-card">
                                    <p class="title elm-title">输入模版信息</p>
                                    <div class="row elm-body" >
                                        <form class="form-horizontal">
                                            <div class="form-group col-lg-9">
                                                <label for="user_name" class="col-lg-2 control-label">模版名称： </label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" v-model="info.name" id="user_name" placeholder="模版名称" name="user_name" datatype="*" errormsg="模版名称错误" nullmsg="模版名称不能为空">
                                                    <span class='Validform_checktip' />
                                                </div>
                                                <label for="user_name" class="col-sm-2 control-label">生效日期： </label>
                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control datetime" :class="'date'+info.ids" id="user_name" placeholder="生效日期" name="user_name" datatype="*" errormsg="请选择时间" nullmsg="请选择时间">
                                                    <span class='Validform_checktip' />
                                                </div>
                                            </div>
                                            <div class="form-group col-lg-9 checkpwrap">
                                                <label for="user_name" class="col-lg-2 control-label">选择人员： </label>
                                                <div class="col-lg-2">
                                                    <select name="" class="form-control checkp" v-model="info.checkP" id="" @change="checkPChange(index)">
                                                        <option value="1">人员</option>
                                                        <option value="3">岗位</option>
                                                    </select>
                                                </div>
                                                <div class="col-lg-8">
                                                    <div v-show="info.checkP == 3" class="postwrap">
                                                        <select datatype="putso" class="form-control post" :class="'post'+info.ids" placeholder="选择岗位" style="width:100%" ></select>
                                                        <span class='Validform_checktip'></span>
                                                    </div>
                                                    <div v-show="info.checkP != 3" class="userwrap">
                                                        <input :id="'userid'+info.ids" class="userid" name="userid" type="hidden" datatype="putso"  errormsg="请选择人员" nullmsg="请选择人员" >
                                                        <div class="departSelect">
                                                            <div type="text" class="form-control tagselect" :id="'user'+info.ids" :class="'treegroup'+info.ids"></div>
                                                            <!-- <div class="form-control" id="treegroup"></div> -->
                                                            <div :id="'groudtree'+info.ids" class="groudtree">
                                                        
                                                            </div>    
                                                        </div>
                                                        <span class='Validform_checktip'></span>
                                                    </div>

                                                </div>
                                            </div>
                                            
                                            <div class="form-group col-lg-9">
                                                <label for="user_name" class="col-lg-2 control-label">考核类型：</label>
                                                <div class="col-lg-2">
                                                    <select name="" v-model="info.type" class="form-control" id="">   
                                                        <option value="2" v-show="!showTypeMonth(info)">上线</option>
                                                        <option value="1" v-show="showTypeMonth(info)">月</option>
                                                    </select>
                                                </div>
                                                
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                <div class="elm-card">
                                    <p class="title elm-title">配置巡视规则</p>
                                    <div class="row elm-body">
                                        <form class="form-horizontal">
                                            <div class="form-group col-lg-9">
                                                <label for="user_name" class="col-sm-2 control-label">巡视网格： </label>
                                                <div class="col-lg-10">
                                                    <select name="grid" class="form-control" :class="'grid'+info.ids" style="width:100%" datatype="select2" errormsg="请选择网格" nullmsg="请选择网格" ></select>
                                                    <span class='Validform_checktip'></span>
                                                </div>
                                                
                                            </div>
                                            <div class="form-group col-lg-9">
                                                <label for="user_name" class="col-lg-2 control-label">巡视频次： </label>
                                                <div class="col-lg-4">
                                                    <select name="" v-model="info.ratetype" class="form-control" id="" style="">
                                                        <option value="1">自定义</option>
                                                        <option value="2">固定</option>
                                                    </select>
                                                </div>
                                                <div class="col-lg-3" v-show="info.ratetype == 2">
                                                    <select name="ratefixed" class="form-control" :class="'ratefixed'+info.ids" style="width:100%" placeholder="固定">
                                                    </select>
                                                </div>
                                                <!-- <template v-show="!isFixed"> -->
                                                        
                                                <div class="col-lg-3" v-show="info.ratetype != 2">
                                                    <select name="rateday" class="form-control" :class="'rateday'+info.ids" style="width:100%">
                                                    </select>
                                                </div>
                                                <div class="col-sm-3" v-show="info.ratetype != 2">
                                                    <select name="ratehour" class="form-control" :class="'ratehour'+info.ids" style="width:100%">
                                                    </select>
                                                </div>
                                                <!-- </template> -->
                                            </div>
                                            <div class="form-group col-lg-3">
                                                <p class="col-sm-5 form-control-static text-right">巡视</p>
                                                <div class="col-sm-5">
                                                    <input name="acount" v-model="info.acount" class="form-control" />
                                                </div>
                                                <p class="form-control-static col-sm-1 text-left">次</p>
                                            </div>
                                            <div class="form-group col-lg-9">
                                                <div class="col-lg-2"></div>
                                                <span class="col-lg-8 ratetip" style="color: #ff5454" :class="'rate'+info.ids"></span>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                </div>
                                <div class="elm-wrap">
                                    <div class="elm-card last elm-card-add" @click="addNewQuan" v-if="showAdd">
                                            <p class="title">+</p>
                                    </div>
                                </div>
                                 
                                <div>
                                    <div class="form-group">
                                        <div class="col-sm-10">
                                            <button type="button" class="btn btn-info edited" onclick="uploadData('quantitave')">提交</button>
                                            <button type="button" class="btn btn-default edit_cancel">取消</button>
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </div> 
                        </div>   
                    </div>
                </div>
            </div>
        </div>
        <footer class="app-footer">
            <div class="wrapper"></div>
        </footer>
        <div class="modal fade" id="modalDel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">删除人员</h4>
                    </div>
                    <div class="modal-body">
                        确定删除人员？
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default cancel" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-info deling">确认</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="modalTips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel3">提示</h4>
                    </div>
                    <div class="modal-body">
                        温馨提示
                    </div>
                </div>
            </div>
        </div>
    </div>
<!-- Javascript Libs -->
<script type="text/javascript" src="../lib/js/jquery.min.js"></script>
<script type="text/javascript" src="../lib/js/common/base.js"></script>
<!-- <script type="text/javascript" src="../lib/js/jquery-1.8.3.min.js"></script> -->
<script type="text/javascript" src="../lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.matchHeight-min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../lib/js/select2.full.min.js"></script>
<script type="text/javascript" src="../lib/js/validform.js"></script>
<script type="text/javascript" src="../lib/js/datetimepicker.js"></script>
<script type="text/javascript" src="../lib/js/dataTables.select.min.js"></script>
<script type="text/javascript" src="../lib/js/depchoice/edep_plugin.js"></script>
<script type="text/javascript" src="../lib/js/ztreeJs.js"></script>
<script src="../lib/js/vue.js"></script>
<!-- <script type="text/javascript" src="../lib/js/ace/ace.js"></script>
<script type="text/javascript" src="../lib/js/ace/mode-html.js"></script>
<script type="text/javascript" src="../lib/js/ace/theme-github.js"></script> -->
<!-- Javascript -->
<script type="text/javascript" src="../lib/js/common/app.js"></script>
<script>
    navData.accNav1 = 'quantitave'
    navData.nav1Name = '量化任务'
    navData.accNav2 = 'quantitave'
    navData.accNav3 = '8'
    var navVue = new Vue({
        el:'.side-menu-wrap' 
    })
    var navTopVue = new Vue({
        el:'.app-header' 
    })
    var Info={}
    var _dataTable = $('.quantable').DataTable({
        "dom": 'rt<"bottom"ip<"clear">>',
        language:{
            url: '../lib/js/cn_lang.json'
        },
        ajax:{
            url:serverUrl.base+serverUrl.quantification+'ListQuantification',
            data:{
                inajax:1
            },
            type:'POST',
            complete:function(){
                $('body').loading('close')
            }
        },
        select:'multi',
        ordering:false,
        buttons:['colvis','excel', 'print','selectAll'],
        columns:[
            {"data":null,defaultContent:'',className: 'select-checkbox'},
            { "data": "quantification_id",defaultContent:'' },
            { "data": "quantification_name",defaultContent:'' },
            { "data": "name","width":'16%',defaultContent:'' },
            { "data": "quantification_check_cycle",render:function(data,type,row,meta){
                if(data == 2){
                    return '上线'
                }else{
                    return '月'
                }
            },defaultContent:'' },
            { "data": "map","width":'25%',render:function(data,type,row,meta){
                var _map=[]
                for(var i=0;i<data.length;i++){
                    _map.push(data[i].grid_name)
                }
                return _map.join(',')
            },defaultContent:'' },
            { "data": "quantification_start_time",defaultContent:'' },
            { "data": "quantification_addtime",defaultContent:''},
            {
                "data":null,render:function(data, type, row, meta){
                    return '<a onclick="editing(\'quantitave\',this)" href="javascript:void(0)">编辑</a> <a onclick="delingModal(\'quantitave\',this)" href="javascript:void(0)">删除</a>'
                },defaultContent:''
            }
            
        ]  
    })
    _dataTable.on('select.dt',function(){
        var selected = _dataTable.rows( { selected: true } ).count()
        var _rows =  _dataTable.rows().count()
        $('.dtcount').text(selected)
        _rows == selected?$('.datatable-checkall').addClass('selected'):$('.datatable-checkall').removeClass('selected')
    })
    _dataTable.on('deselect.dt',function(){
        var selected = _dataTable.rows( { selected: true } ).count()
        $('.datatable-checkall').removeClass('selected')
        $('.dtcount').text(selected)
    })
    $('.datatable-checkall').click(function(){
        $(this).toggleClass('selected')
        if($(this).hasClass('selected')){
            _dataTable.rows().select()
        }else{
            _dataTable.rows().deselect()
        }
        
    })
    //搜索
    function searching(name){
        switch(name){
            case 'quantitave':
                var _upData={
                    'inajax':1,
                    'name':$('.search_name').val(),
                    'type':$('.search_type').val(),
                    'user_work':$('.search_uwork').val()
                }
                _dataTable.settings()[0].ajax.data=_upData
                _dataTable.ajax.reload()
            break;
        }
    } 
    /*
    Vue.component('select2',{
        template:'<div><select :class="name" style="width:100%"></select></div>',
        data: function () {
            return {

            }
        },
        mounted:function(){
            new rpSelect({
                sel:this.name,
                valide:myValidform,
                multiple:false,
                url:serverUrl.base + serverUrl.post + 'post_list',
                placeholder:'请选择岗位'
            })
        },
        props:['name']
    })
    */
    var quantitaveVue = new Vue({
        el:".quantitavevue",
        data:{
            count:0,
            showAdd:true,
            infos:[{
                name:'',//任务名称
                date:'',//任务日期
                checkP:'1',//任务人员类型 1作业人员 3作业岗位
                type:'1',//考核类型（周期） 1月 2上线  
                ratetype:'1',//频次类型 1自定义 2固定
                acount:'', //巡视次数 
                ids:0 //index
            }]
        },
        computed:{
        },
        methods:{
            showTypeMonth:function(v){
                if(v.checkP == 3){
                    v.type = 2
                    return false
                }
                return true
            },
            iseven:function(ids){
                var _b = ids % 2 != 0?true:false
                return {'elm-even':_b}
            },
            checkCp:function(check,ids){
                if(check == 2){
                    var select = new rpSelect({
                        sel:'post'+ids,
                        url:serverUrl.base + serverUrl.post + 'post_list',
                        valide:myValidform,
                        placeholder:'请选择岗位'
                    })
                    return true
                }else{
                   // $('.post'+ids).select2('destroy')
                    return false
                }
            },
            checkPChange:function(ids){
                if(this.infos[ids].checkP == '3'){
                    $('#userid'+this.infos[ids].ids).val('')
                }else{

                }
                //     var select = new rpSelect({
                //         sel:'post'+ids,
                //         url:serverUrl.base + serverUrl.post + 'post_list',
                //         multiple:false,
                //         valide:myValidform,
                //         placeholder:'请选择岗位'
                //     })
                //     $('#userid'+ids).val('')
                // }else{
                //     $(document).off('click','.treegroup'+ids).on('click','.treegroup'+ids,function(){
                //         showsDeptWin('groudtree'+ids,'select','user'+ids,'userid'+ids,'emp',true);
                //     })
                //     $('.post'+ids).select2('destroy')
                // }
            },
            addNewQuan:function(){
                this.count += 1
                this.infos.push({
                    name:'',
                    date:'',
                    checkP:'1',
                    type:'1',
                    ratetype:'1',
                    acount:'',
                    ids:this.count
                })
                newSelect(this.count)
            },
            removeNewQuan:function(ids){
                var _that=this
                this.infos.splice(ids,1)
            }
        },
        created:function(){  
        },
        mounted:function(){
            newSelect(0);
        },
        beforeUpdate:function(){
        },
        updated:function(){         
        },
        watch:{
        }
    })
    //编辑
    function editing(name,elm){
        switch(name){
            case 'quantitave':
                $('.card_edit').show()
                $('.card_list').hide()
                Info = {}
                quantitaveVue.infos = [{
                    name:'',//任务名称
                    date:'',//任务日期
                    checkP:'1',//任务人员类型 1作业人员 3作业岗位
                    type:'1',//考核类型（周期） 1月 2上线  
                    ratetype:'1',//频次类型 1自定义 2固定
                    acount:'0', //巡视次数 
                    ids:0 //index
                }]
                $('.date0').val('')
                $('#userid0').val('');
                $('#user0').html('');
                $('.grid0').val([]).trigger('change')
                if(arguments[1]){   
                    quantitaveVue.showAdd=false
                    Info =$.extend({},_dataTable.row($(elm).parents('tr')).data()) 
                    //console.log(Info)
                    $.get(serverUrl.base+serverUrl.quantification+'AddQuantification',{id:Info.quantification_id},function(res){
                        var _data = res.data
                        quantitaveVue.infos[0].name=_data.list.quantification_name//名称
                        quantitaveVue.infos[0].date=Info.quantification_start_time//日期
                        quantitaveVue.infos[0].checkP=_data.list.quantification_post_type//人员/岗位
                        quantitaveVue.infos[0].type=_data.list.quantification_check_cycle//考核类型（周期）
                        quantitaveVue.infos[0].ratetype=_data.list.quantification_type//巡视频次类型
                        quantitaveVue.infos[0].acount=0 || _data.map.quantification_task_number//巡视次数
                        quantitaveVue.infos[0].id = _data.list.quantification_id
                        $('.date0').val(_data.list.quantification_start_time)

                        if(_data.list.quantification_post_type == '1'){
                            //作业人员
                            var _user = _data.list.quantification_user.split(','),_user_name=_data.list.quantification_user_name.split(',');
                            
                            $('#userid0').val(_data.list.quantification_user);

                            Info._tempUser=[]
                            for(var i=0;i<_user_name.length;i++){
                                Info._tempUser.push({id:_user[i],name:_user_name[i]})
                            }
                            tagSelected({data:Info._tempUser,elmName:'user0',dataName:'userid0'})
                            // tagSelected({data:Info._tempUser,elmName:'user0',delFn:function(elm,id,data){
                            //     Info._tempUser = Info._tempUser.filter(function(v){
                            //         return v.id != id
                            //     })   
                            //     var _tempUser_id = []
                            //     $.each(Info._tempUser,function(val,elm){
                            //         _tempUser_id.push(elm.id)
                            //     })
                            //     $('#userid0').val(_tempUser_id.join(','))
                            // }}) //复选树初始化
                            
                        }else{
                            //作业岗位
                            var _post = _data.list.quantification_user
                            $('.post0').val(_data.list.quantification_user).trigger('change')
                        }
                        //巡视规则
                        var _mapid =_data.map.map_id &&  _data.map.map_id.split(',')
                        $('.grid0').val(_mapid).trigger('change')
                        
                        if(_data.list.quantification_type == 2){
                            $('.ratefixed0').val(_data.map.quantification_task_cycle_h).trigger('change')
                            $('.rateday0').val('0').trigger('change')
                        }else{
                            $('.ratehour0').val(_data.map.quantification_task_cycle_h).trigger('change')
                            $('.rateday0').val(_data.map.quantification_task_cycle_d).trigger('change')
                        }
                        //return false
                    },'json').error(function(res){
                        console.log(res)
                    })
                }else{
                    quantitaveVue.showAdd=true
                }
            break;
            default:
                $('.card_edit').show()
                $('.card_list').hide()
                Info = {}
            break;
        }
        if(arguments[1]){
            Info.row = $(elm).parents('tr')
        }
    }
    //删除
    function delingModal(name,elm){
        var _text={
            tit:'删除',
            body1:'确定删除吗？',
            body2:'删除出现问题',
            btn1:'确定',
            cbtn1:'取消',
            cbtn2:'知道了',
            deltit1:'删除成功',
            deltit2:'删除失败',
            delbody1:"删除成功！",
            delbody2:"出现问题",
        },_datas={
            id:'',
            data:{},
            url:''
        }
        switch(name){
            case 'quantitave':
                if(arguments[1]){
                    Info.row = $(elm).parents('tr')
                    _datas.data={
                        id:[_dataTable.row(Info.row).data().quantification_id]
                    }
                }else{
                    var _tempDatas = _dataTable.rows({selected:true}).data()
                    _datas.data.id=[]  
                    for(var i=0;i<_tempDatas.length;i++){
                        _datas.data.id.push(_tempDatas[i].quantification_id)
                    }
                }

                _datas.url = serverUrl.base+serverUrl.quantification+'DeleteQuantification'
                _text.tit = '删除量化任务'
                _text.body1 = '确定删除量化任务？'
                $('#modalDel').find('.modal-title').text(_text.tit)
                $('#modalDel').find('.modal-body').text(_text.body1)
                $('#modalDel').modal()
            break;
            default:
            break;
        }
        
        $('.deling').off('click').on('click',function(){
            $('.card_list').loading('open')
            $.post(_datas.url,_datas.data,function(res){
                $('#modalDel').modal('hide')
                if(res.code == 0){
                    setTimeout(function(){
                        $('#modalTips').find('.modal-body').text(_text.deltit1)
                        $("#modalTips").modal()    
                    },500)
                    if(Info.row){
                        _dataTable.row(Info.row).remove().draw(false)
                    }else{
                        _dataTable.rows({selected:true}).remove().draw(false)
                    }
                    
                }else{
                    setTimeout(function(){
                        $('#modalTips').find('.modal-body').text(_text.deltit2)
                        $("#modalTips").modal()    
                    },500)
                }
            },'json').error(function(res){
                $('#modalDel').modal('hide')
                setTimeout(function(){
                    $('#modalTips').find('.modal-body').text(_text.delbody2)
                    $("#modalTips").modal()    
                },500)
            }).complete(function(){
                $('.card_list').loading('close')
                $('#modalDel').modal('hide')
            })
        })
        
    }
    
    //提交 
    function uploadData(name){
        switch(name){
            case 'quantitave':
            if(!myValidform.check()){
                return false
            }
            var _complete = true
            var _tempUpData = quantitaveVue.infos
            var _upData=[]
            // infos:[{
            //     name:'',//任务名称
            //     date:'',//任务日期
            //     checkP:'1',//任务人员类型（巡视类别） 1作业人员 2作业岗位
            //     type:'1',//考核类型（周期） 1月 2上线  
            //     ratetype:'1',//频次类型 1自定义 2固定
            //     acount:'', //巡视次数 
            //     ids:0 //index
            // }]
            for(var i=0;i<_tempUpData.length;i++){
                var __mapid = $('.grid'+_tempUpData[i].ids).val() == null?'':$('.grid'+_tempUpData[i].ids).val().join(',')
                
                var __d = {
                    name:_tempUpData[i].name,
                    start_time:$('.date'+_tempUpData[i].ids).val(),//开始时间
                    type:_tempUpData[i].type,
                    user_work:_tempUpData[i].checkP,
                    qu_type:_tempUpData[i].ratetype,
                    user_work_id:'',
                    map_id:__mapid,
                    number:_tempUpData[i].acount,
                    d:$('.rateday'+_tempUpData[i].ids).val(),//day
                    h:$('.ratehour'+_tempUpData[i].ids).val() //hour
                }
                if(_tempUpData[i].id && _tempUpData[i].id != ''){
                    __d.id = _tempUpData[i].id
                }
                if(__d.user_work == '1'){
                    __d.user_work_id = $('#userid'+_tempUpData[i].ids).val()
                }else{
                    console.log($('.post'+_tempUpData[i].ids).val())
                    __d.user_work_id = $('.post'+_tempUpData[i].ids).val()
                }
                if(__d.qu_type == 2){
                    __d.h = $('.ratefixed'+_tempUpData[i].ids).val()
                    __d.d = "0"
                }
                if(__d.number == '0'){
                    $('.rate'+i).html('巡视次数不能为0')
                    _complete = false
                }else{
                    $('.rate'+i).html('')
                }
                if(__d.h == '0' && __d.d == '0'){
                    $('.rate'+i).html('巡视频次不正常')
                    _complete = false
                }else{
                    $('.rate'+i).html('')
                }
                _upData.push(__d)
                
            }
           
            //console.log(_upData);
            //return false
            if(_complete){
                $('.card_edit').loading('open')
                _complete = false
                $.ajax({
                    url:serverUrl.base+serverUrl.quantification+'AddQuantification',
                    type:"POST",
                    data:{qu_arrs:_upData},
                    dataType:"json",
                    success:function(res){
                        if(res.code == 0){
                            //更新表格
                            // _dataTable.settings()[0].ajax.data={'department_id':Info.department_id}
                            // _dataTable.ajax.reload()
                            // console.log('成功')
                            // return false
                            // if(Info.row){
                            //     Info.row.deselect();
                            //     _dataTable.row(Info.row).data(upData).draw(false)
                            // }else{
                            //     _dataTable.row.add(upData).draw(false)
                            // }
                            
                            _dataTable.ajax.reload()
                            $("#modalTips").find('.modal-title').text('成功') 
                            var _info=''
                            if(Info.row){
                                _info = '量化任务修改成功！'
                            }else{
                                _info = '量化任务添加成功！'
                            }
                            $("#modalTips").find('.modal-body').text(_info)
                        }else if(res.code == '2'){
                            $("#modalTips").find('.modal-title').text('出现问题') 
                            $("#modalTips").find('.modal-body').text('请检查，出现问题')
                        }else{
                            $("#modalTips").find('.modal-title').text(res.info) 
                            $("#modalTips").find('.modal-body').text(res.data)
                        }
                        setTimeout(function(){
                            $("#modalTips").modal()    
                        },500)
                        $('.card_edit').hide()
                        $('.card_list').show()
                        Info = {}
                    },
                    complete:function(res){
                        $('#modalDel').modal('hide');
                        _complete = true
                        $('.card_edit').loading('close')
                    },
                    error:function(res){
                        $("#modalTips").find('.modal-title').text('出现问题') 
                        $("#modalTips").find('.modal-body').text(res.info)
                        setTimeout(function(){
                            $("#modalTips").modal()    
                        },500)
                    }    
                })
            }
            
            break;
        }
    }
    //取消
    $('.edit_cancel').on('click',function(){
        Info.row && _dataTable.row(Info.row).deselect()
        Info={}
        $('.card_edit').hide()
        $('.card_list').show()
    })
    var myValidform = $(".ss_form").Validform({
        tiptype:3,
        datatype:{
            putso:function(gets,obj,curform,regxp){
                /*参数gets是获取到的表单元素值，
				  obj为当前表单元素，
				  curform为当前验证的表单，
				  regxp为内置的一些正则表达式的引用。*/
                var _checkpwrap = obj.parents('.checkpwrap')
                var _type = _checkpwrap.find('.checkp').val()
                var _userid = _checkpwrap.find('.userid').val()
                var _post = _checkpwrap.find('.post').val()
                var reg1=regxp["*"],
					reg2=/[\d]{7}/,
					mobile=curform.find(".mobile");
                if(obj){
                    if(_type == '1'){
                        //人
                        //console.log(_userid)
                        if(reg1.test(_userid)){return true;}
                    }else if(_type == '3'){
                        //岗位
                        if(reg1.test(_post)){return true;}
                    }
                }
                return false;
            },
            ztreegroup:function(gets,obj,curform,regxp){
                console.log(gets)
                if(gets == ''){
                    return false
                }else{
                }
            },
            select2:function(gets,obj,curform,regxp){
                if(gets.length ==0){
                    obj.siblings('.select2').find('.select2-selection').css('borderColor','red')
                    return false
                }else{
                    obj.siblings('.select2').find('.select2-selection').css('borderColor','#ccc')
                }
            }
        }
    });   
    function newSelect(ids){
        setTimeout(function(){
            $(".date"+ids).datetimepicker({
                timepicker: false,
                format:'Y-m-d',
                minDate:'-1969/12/31'
            });
            
            myValidform = $(".ss_form").Validform({
                tiptype:3
            }); 
            $(document).off('click','.treegroup'+ids).on('click','.treegroup'+ids,function(){
                showsDeptWin('user'+ids,'userid'+ids,"1",myValidform);
            }) 
        },0)
        myValidform = $(".ss_form").Validform({
                tiptype:3
            });  
        var select = new rpSelect({
            sel:'post'+ids,
            data:{post_type_id:'2',post_duty:'3'},
            valide:myValidform,
            multiple:false,
            url:serverUrl.base + serverUrl.post + 'post_list',
            placeholder:'请选择岗位'
        })
        var selectGrip = new rpSelect({
            sel:'grid'+ids,
            url:serverUrl.base+serverUrl.grid+'grid_choice_list',
            placeholder:'选择责任网格',
            valide:myValidform
        })
        
        var selectDay = new rpSelect({
            sel:'rateday'+ids,
            datas:select2Datas.day,
            valide:myValidform,
            multiple:false,
            placeholder:'天数'
        })
        var selectHour = new rpSelect({
            sel:'ratehour'+ids,
            datas:select2Datas.hour,
            multiple:false,
            valide:myValidform,
            placeholder:'小时数'
        })
        var selectFixed = new rpSelect({
            sel:'ratefixed'+ids,
            datas:select2Datas.quantiRate,
            valide:myValidform,
            multiple:false,
            placeholder:'巡视类型'
        })
    }
    
</script>
</body>

</html>
